Repository navigation
fix: don't leak GC roots in Table::copy - #14627
Merged
Merged
Conversation
`Table::copy` copies each element by reading it with `Table::get` and writing it with `Table::set`. For GC reference tables, `Table::get` creates a LIFO `Rooted` in the caller's current root scope. Nothing in `Table::copy` released those roots, so when it was called on a plain `&mut Store` rather than inside a `RootScope`, every copied object stayed rooted until the store was dropped. Repeated copies grew the root set and kept the GC heap from shrinking across collections. Enter a GC LIFO scope around each element's get/set pair and exit it afterwards, so the temporary root is released before the next element is copied. Assisted-by: claude:claude-opus-5-5 Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
alexcrichton
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Table::copycopies each element by reading it withTable::getand writing it withTable::set. For GC reference tables,Table::getcreates a LIFORootedin the caller's current root scope. Nothing inTable::copyreleased those roots, so when it was called on a plain&mut Storerather than inside aRootScope, every copied object stayed rooted until the store was dropped. Repeated copies grew the root set and kept the GC heap from shrinking across collections.Enter a GC LIFO scope around each element's get/set pair and exit it afterwards, so the temporary root is released before the next element is copied.